function [p,rho,mu,T,sound,delta_isa]=isa_cos(alt,temp,flag)

% flag==1 -> temp means delta ISA in K
% flag==0 -> temp means the absolute temperature in K

% ISA Reference Data	Symbol	Value	Unit
% Thermal gradient	lambda	-6,50E-03	[ K/m ]
% MSL temperature	T_0	288,15	[ K ]
% MSL pressure	P_0	101325	[ Pa ]
% MSL density	rho_0	1,225	[ kg/m^3 ]
% Gravity aceleration	g	9,81	[ m/s^2 ]
% Perfect gas constant	R_perf	8,31432	[ J/ mol.K ]
% Air molecular mass	M_ar	0,0289644	[ kg/ mol]
% Sutherland constant	S_ar ou C_ar	110,4	[ K ]
% MSL dynamic viscosity	mu_0	1,79E-05	[ kg/m.s ]
% MSL kinematic viscosity	nu_0	1,46E-05	[ m^2/s ]
% Heat capacity ratio	gama	1,4	[ -- ]
% Air specific constant	R_ar	287,053072	[ m^2/s^2.K ]

lambda=-6.50E-03;
T_0=288.15;
P_0=101325;
rho_0=1.225;
g=9.81;
R_perf=8.31432;
M_ar=0.0289644;
S_ar=110.4;
mu_0=1.79E-05;
gama=1.4;

R_ar=R_perf/M_ar;

T_isa=T_0+lambda*alt;

if flag==1
    T=T_isa+temp;
    delta_isa=temp;
elseif flag==0
    T=temp;
    delta_isa=temp-T_isa;
end

p=P_0*((T_0+delta_isa+lambda*alt)/T_0)^(-g/(R_ar*lambda));
rho=rho_0*((T_0+delta_isa+lambda*alt)/T_0)^(-g/(R_ar*lambda)-1);
sound=sqrt(gama*p/rho);
mu=mu_0*((T_0+S_ar)/(T+S_ar))*(T/T_0)^(3/2);
